from concurrent.futures import ThreadPoolExecutor
import random
import time
import requests
import uuid
import json
import sys
import os

sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))

from model.car_number import CarNumber

from common.logger import logger
from spider.su_park import SuParkSpider
from account.su_account_service import SuAccountService
from model.proxy import Proxy

import spider_config

# 生成guid


import threading

write_lock = threading.RLock()

accounts = [
    "pp_user_hash=ba85cc0e69; tgw_l7_route=d925f45429cc0e1a41f59c1d7de75231; pp_user_id=539159713059104397; ",
    "pp_user_id=539163539877897594;pp_user_hash=67f9d7f923",
    "pp_user_hash=776b3919aa; pp_phone_hash=e7e827ce; pp_user_id=56868197392983333; ",
    "pp_user_hash=1e1739b0f0; tgw_l7_route=b63002a0575cab8cadf9277188c1f4e4; pp_user_id=539169015944581653; ",
    "pp_user_hash=59b7759330; tgw_l7_route=d925f45429cc0e1a41f59c1d7de75231; pp_user_id=539169015944581704; ",
    "pp_user_hash=43ce76d95d; tgw_l7_route=d925f45429cc0e1a41f59c1d7de75231; pp_user_id=539159713059105025; ",
]

def test():
    account = SuAccountService()
    account.active()
    spider = SuParkSpider()
    # spider.setAccount({"userid": "56868197392983333", "userhash": "776b3919aa"})
    spider.setAccount({"userid": "539159713059102858", "userhash": "bc026b0431"})
    while True:
        #spider.setProxy(get_proxy())
        logger.success(spider.query(CarNumber("鄂A11111")))
        # time.sleep(1)


if __name__ == "__main__":
    thread_count = 10

    test()
    # thread_pool = ThreadPoolExecutor(max_workers=thread_count)

    # futures = []
    # for i in range(thread_count):
    #     futures.append(thread_pool.submit(test))

    # thread_pool.shutdown(wait=True)
